| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.android.compat.testing; |
| 18 |
|
| 19 |
import android.compat.Compatibility; |
| 20 |
import android.content.Context; |
| 21 |
import android.os.RemoteException; |
| 22 |
import android.os.ServiceManager; |
| 23 |
|
| 24 |
import com.android.internal.compat.IPlatformCompat; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public class DummyApi { |
| 32 |
|
| 33 |
public static final long CHANGE_ID = 666013; |
| 34 |
public static final long CHANGE_ID_1 = 666014; |
| 35 |
public static final long CHANGE_ID_2 = 666015; |
| 36 |
public static final long CHANGE_SYSTEM_SERVER = 666016; |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
public static String dummyFunc() { |
| 43 |
if (Compatibility.isChangeEnabled(CHANGE_ID)) { |
| 44 |
return "A"; |
| 45 |
} |
| 46 |
return "B"; |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
public static String dummyCombinedFunc() { |
| 57 |
if (!Compatibility.isChangeEnabled(CHANGE_ID_1) |
| 58 |
&& !Compatibility.isChangeEnabled(CHANGE_ID_2)) { |
| 59 |
return "0"; |
| 60 |
} else if (!Compatibility.isChangeEnabled(CHANGE_ID_1) |
| 61 |
&& Compatibility.isChangeEnabled(CHANGE_ID_2)) { |
| 62 |
return "1"; |
| 63 |
} else if (Compatibility.isChangeEnabled(CHANGE_ID_1) |
| 64 |
&& !Compatibility.isChangeEnabled(CHANGE_ID_2)) { |
| 65 |
return "2"; |
| 66 |
} |
| 67 |
return "3"; |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
public static boolean dummySystemServer(Context context) { |
| 74 |
IPlatformCompat platformCompat = IPlatformCompat.Stub |
| 75 |
.asInterface(ServiceManager.getService(Context.PLATFORM_COMPAT_SERVICE)); |
| 76 |
if (platformCompat == null) { |
| 77 |
throw new RuntimeException("Could not obtain IPlatformCompat instance!"); |
| 78 |
} |
| 79 |
String packageName = context.getPackageName(); |
| 80 |
try { |
| 81 |
return platformCompat.isChangeEnabledByPackageName(CHANGE_SYSTEM_SERVER, packageName, |
| 82 |
context.getUserId()); |
| 83 |
} catch (RemoteException e) { |
| 84 |
throw new RuntimeException("Could not get change value!", e); |
| 85 |
} |
| 86 |
} |
| 87 |
} |