Android-x86
Fork
Faire un don

  • R/O
  • HTTP
  • SSH
  • HTTPS

packages-apps-Taskbar: Commit

packages/apps/Taskbar


Commit MetaInfo

Révision8db44932f33c88f07d45dcfb0af77d953c4a6b72 (tree)
l'heure2020-03-23 12:10:40
AuteurBraden Farmer <farmerbb@gmai...>
CommiterBraden Farmer

Message de Log

Laying some of the groundwork for the additional desktop mode settings

Change Summary

Modification

--- a/app/src/main/java/com/farmerbb/taskbar/util/U.java
+++ b/app/src/main/java/com/farmerbb/taskbar/util/U.java
@@ -1214,15 +1214,7 @@ public class U {
12141214 if(context.getPackageName().equals(BuildConfig.ANDROIDX86_APPLICATION_ID))
12151215 return true;
12161216
1217- PackageManager pm = context.getPackageManager();
1218- try {
1219- pm.getPackageInfo(BuildConfig.SUPPORT_APPLICATION_ID, 0);
1220- return pm.checkSignatures(BuildConfig.SUPPORT_APPLICATION_ID, context.getPackageName()) == PackageManager.SIGNATURE_MATCH
1221- && context.getPackageName().equals(BuildConfig.BASE_APPLICATION_ID)
1222- && isSystemApp(context);
1223- } catch (PackageManager.NameNotFoundException e) {
1224- return false;
1225- }
1217+ return hasSupportLibrary(context, 0);
12261218 }
12271219
12281220 public static boolean hasSupportLibrary(Context context, int minVersion) {
@@ -1320,18 +1312,38 @@ public class U {
13201312 }
13211313
13221314 public static void showHideNavigationBar(Context context, boolean show) {
1315+ if(!isDesktopModeActive(context)
1316+ && !isBlissOs(context)
1317+ && !hasSupportLibrary(context, 7)) {
1318+ return;
1319+ }
1320+
1321+ int displayID = getDisplayID();
1322+ int value = show ? 0 : getNavbarHeight(context) * -1;
1323+
1324+ if(hasWriteSecureSettingsPermission(context)) {
1325+ try {
1326+ setOverscan(displayID, value);
1327+ return;
1328+ } catch (Exception e) {
1329+ // Fallback to next method
1330+ }
1331+ }
1332+
13231333 if(hasSupportLibrary(context, 7)) {
13241334 Intent intent = new Intent(BuildConfig.SUPPORT_APPLICATION_ID + ".CHANGE_OVERSCAN");
13251335 intent.setPackage(BuildConfig.SUPPORT_APPLICATION_ID);
13261336
1327- intent.putExtra("display_id", getDisplayID());
1328- intent.putExtra("value", show ? 0 : getNavbarHeight(context) * -1);
1337+ intent.putExtra("display_id", displayID);
1338+ intent.putExtra("value", value);
13291339
13301340 context.sendBroadcast(intent);
13311341 return;
13321342 }
13331343
13341344 // Show or hide the system navigation bar on Bliss-x86
1345+ if(!isBlissOs(context)) return;
1346+
13351347 try {
13361348 if(getCurrentApiVersion() >= 28.0f)
13371349 Settings.Secure.putInt(context.getContentResolver(), "navigation_bar_visible", show ? 1 : 0);
@@ -1857,10 +1869,43 @@ public class U {
18571869 && !pref.getBoolean("launcher", false);
18581870 }
18591871
1872+ // TODO remove this in favor of the existing getDisplayID method?
18601873 public static int getExternalDisplayID(Context context) {
18611874 DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
18621875 Display[] displays = dm.getDisplays();
18631876
18641877 return displays[displays.length - 1].getDisplayId();
18651878 }
1879+
1880+ @SuppressLint("PrivateApi")
1881+ private static Object getWindowManagerService() throws Exception {
1882+ return Class.forName("android.view.WindowManagerGlobal")
1883+ .getMethod("getWindowManagerService")
1884+ .invoke(null);
1885+ }
1886+
1887+ @SuppressLint("PrivateApi")
1888+ private static void setDensity(int displayID, String value) throws Exception {
1889+ // From android.os.UserHandle
1890+ final int USER_CURRENT_OR_SELF = -3;
1891+
1892+ if(value.equals("reset")) {
1893+ Class.forName("android.view.IWindowManager")
1894+ .getMethod("clearForcedDisplayDensityForUser", int.class, int.class)
1895+ .invoke(getWindowManagerService(), displayID, USER_CURRENT_OR_SELF);
1896+ } else {
1897+ int density = Integer.parseInt(value);
1898+
1899+ Class.forName("android.view.IWindowManager")
1900+ .getMethod("setForcedDisplayDensityForUser", int.class, int.class, int.class)
1901+ .invoke(getWindowManagerService(), displayID, density, USER_CURRENT_OR_SELF);
1902+ }
1903+ }
1904+
1905+ @SuppressLint("PrivateApi")
1906+ private static void setOverscan(int displayID, int value) throws Exception {
1907+ Class.forName("android.view.IWindowManager")
1908+ .getMethod("setOverscan", int.class, int.class, int.class, int.class, int.class)
1909+ .invoke(getWindowManagerService(), displayID, 0, 0, 0, value);
1910+ }
18661911 }
--- a/app/src/playstore/java/com/farmerbb/taskbar/TaskbarApplication.java
+++ b/app/src/playstore/java/com/farmerbb/taskbar/TaskbarApplication.java
@@ -12,7 +12,7 @@ public class TaskbarApplication extends Application {
1212 protected void attachBaseContext(Context base) {
1313 super.attachBaseContext(base);
1414
15- if(U.getCurrentApiVersion() > 29.0f)
15+ if(U.getCurrentApiVersion() > 29.0f || U.isDesktopModeSupported(base))
1616 Reflection.unseal(base);
1717 }
1818 }
\ No newline at end of file
Afficher sur ancien navigateur de dépôt.