Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4e81740f authored by Peiyong Lin's avatar Peiyong Lin Committed by Automerger Merge Worker
Browse files

Merge "Return success when the command is executed." into sc-dev am: 79a5f7ab

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15179875

Change-Id: Ic68ff0146f0a220192daddeaff64be47dd08c60d
parents 77486b73 79a5f7ab
Loading
Loading
Loading
Loading
+69 −60
Original line number Original line Diff line number Diff line
@@ -36,7 +36,9 @@ import android.app.GameManager;
import android.app.IGameManagerService;
import android.app.IGameManagerService;
import android.compat.Compatibility;
import android.compat.Compatibility;
import android.content.Context;
import android.content.Context;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceManager;
import android.os.ServiceManager.ServiceNotFoundException;
import android.os.ShellCommand;
import android.os.ShellCommand;
import android.util.ArraySet;
import android.util.ArraySet;


@@ -116,7 +118,7 @@ public class GameManagerShellCommand extends ShellCommand {
                        pw.println("Enable downscaling ratio for " + packageName + " to " + ratio);
                        pw.println("Enable downscaling ratio for " + packageName + " to " + ratio);
                    }
                    }


                    break;
                    return 0;
                }
                }
                case "mode": {
                case "mode": {
                    /** The "mode" command allows setting a package's current game mode outside of
                    /** The "mode" command allows setting a package's current game mode outside of
@@ -128,6 +130,18 @@ public class GameManagerShellCommand extends ShellCommand {
                     *          <PACKAGE_NAME> <CONFIG_STRING>`
                     *          <PACKAGE_NAME> <CONFIG_STRING>`
                     * see: {@link GameManagerServiceTests#mockDeviceConfigAll()}
                     * see: {@link GameManagerServiceTests#mockDeviceConfigAll()}
                     */
                     */
                    return runGameMode(pw);
                }
                default:
                    return handleDefaultCommands(cmd);
            }
        } catch (Exception e) {
            pw.println("Error: " + e);
        }
        return -1;
    }

    private int runGameMode(PrintWriter pw) throws ServiceNotFoundException, RemoteException {
        final String option = getNextOption();
        final String option = getNextOption();
        String userIdStr = null;
        String userIdStr = null;
        if (option != null && option.equals("--user")) {
        if (option != null && option.equals("--user")) {
@@ -160,6 +174,7 @@ public class GameManagerShellCommand extends ShellCommand {
                } else {
                } else {
                    pw.println("Game mode: " + gameMode + " not supported by "
                    pw.println("Game mode: " + gameMode + " not supported by "
                            + packageName);
                            + packageName);
                    return -1;
                }
                }
                break;
                break;
            case "2":
            case "2":
@@ -170,6 +185,7 @@ public class GameManagerShellCommand extends ShellCommand {
                } else {
                } else {
                    pw.println("Game mode: " + gameMode + " not supported by "
                    pw.println("Game mode: " + gameMode + " not supported by "
                            + packageName);
                            + packageName);
                    return -1;
                }
                }
                break;
                break;
            case "3":
            case "3":
@@ -180,22 +196,15 @@ public class GameManagerShellCommand extends ShellCommand {
                } else {
                } else {
                    pw.println("Game mode: " + gameMode + " not supported by "
                    pw.println("Game mode: " + gameMode + " not supported by "
                            + packageName);
                            + packageName);
                    return -1;
                }
                }
                break;
                break;
            default:
            default:
                pw.println("Invalid game mode: " + gameMode);
                pw.println("Invalid game mode: " + gameMode);
                            break;
                    }
                    break;
                }
                default:
                    return handleDefaultCommands(cmd);
            }
        } catch (Exception e) {
            pw.println("Error: " + e);
        }
                return -1;
                return -1;
        }
        }
        return 0;
    }




    @Override
    @Override