diff options
Diffstat (limited to 'cmds')
| -rw-r--r-- | cmds/am/src/com/android/commands/am/Am.java | 22 | ||||
| -rw-r--r-- | cmds/bootanimation/BootAnimation.cpp | 19 | ||||
| -rw-r--r-- | cmds/bootanimation/BootAnimation.h | 1 | ||||
| -rw-r--r-- | cmds/pm/src/com/android/commands/pm/Pm.java | 24 |
4 files changed, 52 insertions, 14 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index d6c00589e7c2..c460b048a3b7 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -48,7 +48,9 @@ import android.content.pm.InstrumentationInfo; import android.content.pm.ParceledListSlice; import android.content.pm.ResolveInfo; import android.content.pm.UserInfo; +import android.content.res.AssetManager; import android.content.res.Configuration; +import android.content.res.Resources; import android.graphics.Rect; import android.os.Binder; import android.os.Build; @@ -64,6 +66,7 @@ import android.os.UserHandle; import android.text.TextUtils; import android.util.AndroidException; import android.util.ArrayMap; +import android.util.DisplayMetrics; import android.view.IWindowManager; import com.android.internal.os.BaseCommand; @@ -361,6 +364,8 @@ public class Am extends BaseCommand { "am send-trim-memory: send a memory trim event to a <PROCESS>.\n" + "\n" + "am get-current-user: returns id of the current foreground user.\n" + + "\n" + + "am supports-multiwindow: returns true if the device supports multiwindow.\n" + "\n" ); Intent.printIntentArgsHelp(pw, ""); @@ -458,6 +463,8 @@ public class Am extends BaseCommand { runSendTrimMemory(); } else if (op.equals("get-current-user")) { runGetCurrentUser(); + } else if (op.equals("supports-multiwindow")) { + runSupportsMultiwindow(); } else { showError("Error: unknown command '" + op + "'"); } @@ -2534,6 +2541,21 @@ public class Am extends BaseCommand { System.out.println(currentUser.id); } + private void runSupportsMultiwindow() throws Exception { + // system resources does not contain all the device configuration, construct it manually. + Configuration config = mAm.getConfiguration(); + if (config == null) { + throw new AndroidException("Activity manager has no configuration"); + } + + final DisplayMetrics metrics = new DisplayMetrics(); + metrics.setToDefaults(); + + Resources res = new Resources(AssetManager.getSystem(), metrics, config); + + System.out.println(res.getBoolean(com.android.internal.R.bool.config_supportsMultiWindow)); + } + /** * Open the given file for sending into the system process. This verifies * with SELinux that the system will have access to the file. diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index c9211939ec6c..9cfef47b2ea1 100644 --- a/cmds/bootanimation/BootAnimation.cpp +++ b/cmds/bootanimation/BootAnimation.cpp @@ -74,6 +74,7 @@ static const char LAST_TIME_CHANGED_FILE_NAME[] = "last_time_change"; static const char LAST_TIME_CHANGED_FILE_PATH[] = "/data/system/time/last_time_change"; static const char ACCURATE_TIME_FLAG_FILE_NAME[] = "time_is_accurate"; static const char ACCURATE_TIME_FLAG_FILE_PATH[] = "/data/system/time/time_is_accurate"; +static const char TIME_FORMAT_12_HOUR_FLAG_FILE_PATH[] = "/data/system/time/time_format_12_hour"; // Java timestamp format. Don't show the clock if the date is before 2000-01-01 00:00:00. static const long long ACCURATE_TIME_EPOCH = 946684800000; static constexpr char FONT_BEGIN_CHAR = ' '; @@ -99,7 +100,7 @@ static const std::vector<std::string> PLAY_SOUND_BOOTREASON_BLACKLIST { // --------------------------------------------------------------------------- BootAnimation::BootAnimation() : Thread(false), mClockEnabled(true), mTimeIsAccurate(false), - mTimeCheckThread(NULL) { + mTimeFormat12Hour(false), mTimeCheckThread(NULL) { mSession = new SurfaceComposerClient(); // If the system has already booted, the animation is not being used for a boot. @@ -590,9 +591,10 @@ void BootAnimation::drawText(const char* str, const Font& font, bool bold, int* glBindTexture(GL_TEXTURE_2D, 0); } -// We render 24 hour time. +// We render 12 or 24 hour time. void BootAnimation::drawClock(const Font& font, const int xPos, const int yPos) { - static constexpr char TIME_FORMAT[] = "%H:%M"; + static constexpr char TIME_FORMAT_12[] = "%l:%M"; + static constexpr char TIME_FORMAT_24[] = "%H:%M"; static constexpr int TIME_LENGTH = 6; time_t rawtime; @@ -600,7 +602,8 @@ void BootAnimation::drawClock(const Font& font, const int xPos, const int yPos) struct tm* timeInfo = localtime(&rawtime); char timeBuff[TIME_LENGTH]; - size_t length = strftime(timeBuff, TIME_LENGTH, TIME_FORMAT, timeInfo); + const char* timeFormat = mTimeFormat12Hour ? TIME_FORMAT_12 : TIME_FORMAT_24; + size_t length = strftime(timeBuff, TIME_LENGTH, timeFormat, timeInfo); if (length != TIME_LENGTH - 1) { ALOGE("Couldn't format time; abandoning boot animation clock"); @@ -608,9 +611,10 @@ void BootAnimation::drawClock(const Font& font, const int xPos, const int yPos) return; } + char* out = timeBuff[0] == ' ' ? &timeBuff[1] : &timeBuff[0]; int x = xPos; int y = yPos; - drawText(timeBuff, font, false, &x, &y); + drawText(out, font, false, &x, &y); } bool BootAnimation::parseAnimationDesc(Animation& animation) @@ -1062,6 +1066,11 @@ bool BootAnimation::updateIsTimeAccurate() { } struct stat statResult; + + if(stat(TIME_FORMAT_12_HOUR_FLAG_FILE_PATH, &statResult) == 0) { + mTimeFormat12Hour = true; + } + if(stat(ACCURATE_TIME_FLAG_FILE_PATH, &statResult) == 0) { mTimeIsAccurate = true; return true; diff --git a/cmds/bootanimation/BootAnimation.h b/cmds/bootanimation/BootAnimation.h index 42759f1acf0d..7a2e4c28f767 100644 --- a/cmds/bootanimation/BootAnimation.h +++ b/cmds/bootanimation/BootAnimation.h @@ -152,6 +152,7 @@ private: sp<Surface> mFlingerSurface; bool mClockEnabled; bool mTimeIsAccurate; + bool mTimeFormat12Hour; bool mSystemBoot; String8 mZipFileName; SortedVector<String8> mLoadedFiles; diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java index 5f83d191a731..1b4eda804312 100644 --- a/cmds/pm/src/com/android/commands/pm/Pm.java +++ b/cmds/pm/src/com/android/commands/pm/Pm.java @@ -367,18 +367,24 @@ public final class Pm { private int runInstall() throws RemoteException { final InstallParams params = makeInstallParams(); final String inPath = nextArg(); + boolean installExternal = + (params.sessionParams.installFlags & PackageManager.INSTALL_EXTERNAL) != 0; if (params.sessionParams.sizeBytes < 0 && inPath != null) { File file = new File(inPath); if (file.isFile()) { - try { - ApkLite baseApk = PackageParser.parseApkLite(file, 0); - PackageLite pkgLite = new PackageLite(null, baseApk, null, null, null); - params.sessionParams.setSize( - PackageHelper.calculateInstalledSize(pkgLite, false, - params.sessionParams.abiOverride)); - } catch (PackageParserException | IOException e) { - System.err.println("Error: Failed to parse APK file : " + e); - return 1; + if (installExternal) { + try { + ApkLite baseApk = PackageParser.parseApkLite(file, 0); + PackageLite pkgLite = new PackageLite(null, baseApk, null, null, null); + params.sessionParams.setSize( + PackageHelper.calculateInstalledSize(pkgLite, false, + params.sessionParams.abiOverride)); + } catch (PackageParserException | IOException e) { + System.err.println("Error: Failed to parse APK file : " + e); + return 1; + } + } else { + params.sessionParams.setSize(file.length()); } } } |