| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.app; |
| 18 |
|
| 19 |
import android.compat.Compatibility; |
| 20 |
import android.os.Process; |
| 21 |
|
| 22 |
import com.android.internal.compat.ChangeReporter; |
| 23 |
|
| 24 |
import java.util.Arrays; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public final class AppCompatCallbacks implements Compatibility.BehaviorChangeDelegate { |
| 32 |
private final long[] mDisabledChanges; |
| 33 |
private final ChangeReporter mChangeReporter; |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
public static void install(long[] disabledChanges) { |
| 41 |
Compatibility.setBehaviorChangeDelegate(new AppCompatCallbacks(disabledChanges)); |
| 42 |
} |
| 43 |
|
| 44 |
private AppCompatCallbacks(long[] disabledChanges) { |
| 45 |
mDisabledChanges = Arrays.copyOf(disabledChanges, disabledChanges.length); |
| 46 |
Arrays.sort(mDisabledChanges); |
| 47 |
mChangeReporter = new ChangeReporter( |
| 48 |
ChangeReporter.SOURCE_APP_PROCESS); |
| 49 |
} |
| 50 |
|
| 51 |
public void onChangeReported(long changeId) { |
| 52 |
reportChange(changeId, ChangeReporter.STATE_LOGGED); |
| 53 |
} |
| 54 |
|
| 55 |
public boolean isChangeEnabled(long changeId) { |
| 56 |
if (Arrays.binarySearch(mDisabledChanges, changeId) < 0) { |
| 57 |
|
| 58 |
reportChange(changeId, ChangeReporter.STATE_ENABLED); |
| 59 |
return true; |
| 60 |
} |
| 61 |
reportChange(changeId, ChangeReporter.STATE_DISABLED); |
| 62 |
return false; |
| 63 |
} |
| 64 |
|
| 65 |
private void reportChange(long changeId, int state) { |
| 66 |
int uid = Process.myUid(); |
| 67 |
mChangeReporter.reportChange(uid, changeId, state); |
| 68 |
} |
| 69 |
|
| 70 |
} |