| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.android.wm.shell.desktopmode; |
| 18 |
|
| 19 |
import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE; |
| 20 |
|
| 21 |
import android.content.Context; |
| 22 |
import android.os.SystemProperties; |
| 23 |
import android.os.UserHandle; |
| 24 |
import android.provider.Settings; |
| 25 |
|
| 26 |
import com.android.internal.protolog.common.ProtoLog; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public class DesktopModeStatus { |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
private static final boolean IS_SUPPORTED = SystemProperties.getBoolean( |
| 37 |
"persist.wm.debug.desktop_mode", false); |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
private static final boolean IS_PROTO2_ENABLED = SystemProperties.getBoolean( |
| 43 |
"persist.wm.debug.desktop_mode_2", false); |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
public static boolean isProto1Enabled() { |
| 49 |
return IS_SUPPORTED; |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
public static boolean isProto2Enabled() { |
| 56 |
return IS_PROTO2_ENABLED; |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
public static boolean isAnyEnabled() { |
| 64 |
return isProto1Enabled() || isProto2Enabled(); |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
public static boolean isActive(Context context) { |
| 73 |
if (!isAnyEnabled()) { |
| 74 |
return false; |
| 75 |
} |
| 76 |
if (isProto2Enabled()) { |
| 77 |
|
| 78 |
return true; |
| 79 |
} |
| 80 |
try { |
| 81 |
int result = Settings.System.getIntForUser(context.getContentResolver(), |
| 82 |
Settings.System.DESKTOP_MODE, UserHandle.USER_CURRENT); |
| 83 |
return result != 0; |
| 84 |
} catch (Exception e) { |
| 85 |
ProtoLog.e(WM_SHELL_DESKTOP_MODE, "Failed to read DESKTOP_MODE setting %s", e); |
| 86 |
return false; |
| 87 |
} |
| 88 |
} |
| 89 |
} |