mirror of
				https://github.com/libsdl-org/SDL.git
				synced 2025-11-04 01:34:38 +00:00 
			
		
		
		
	Android: improve check to know if running on ChromeBook or emulator.
https://stackoverflow.com/questions/39784415/how-to-detect-programmatically-if-android-app-is-running-in-chrome-book-or-in
This commit is contained in:
		@@ -161,7 +161,7 @@ class HIDDeviceBLESteamController extends BluetoothGattCallback implements HIDDe
 | 
				
			|||||||
        mDevice = device;
 | 
					        mDevice = device;
 | 
				
			||||||
        mDeviceId = mManager.getDeviceIDForIdentifier(getIdentifier());
 | 
					        mDeviceId = mManager.getDeviceIDForIdentifier(getIdentifier());
 | 
				
			||||||
        mIsRegistered = false;
 | 
					        mIsRegistered = false;
 | 
				
			||||||
        mIsChromebook = mManager.getContext().getPackageManager().hasSystemFeature("org.chromium.arc.device_management");
 | 
					        mIsChromebook = SDLActivity.isChromebook();
 | 
				
			||||||
        mOperations = new LinkedList<GattOperation>();
 | 
					        mOperations = new LinkedList<GattOperation>();
 | 
				
			||||||
        mHandler = new Handler(Looper.getMainLooper());
 | 
					        mHandler = new Handler(Looper.getMainLooper());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -108,7 +108,7 @@ public class HIDDeviceManager {
 | 
				
			|||||||
        HIDDeviceRegisterCallback();
 | 
					        HIDDeviceRegisterCallback();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        mSharedPreferences = mContext.getSharedPreferences("hidapi", Context.MODE_PRIVATE);
 | 
					        mSharedPreferences = mContext.getSharedPreferences("hidapi", Context.MODE_PRIVATE);
 | 
				
			||||||
        mIsChromebook = mContext.getPackageManager().hasSystemFeature("org.chromium.arc.device_management");
 | 
					        mIsChromebook = SDLActivity.isChromebook();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//        if (shouldClear) {
 | 
					//        if (shouldClear) {
 | 
				
			||||||
//            SharedPreferences.Editor spedit = mSharedPreferences.edit();
 | 
					//            SharedPreferences.Editor spedit = mSharedPreferences.edit();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1331,10 +1331,17 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
 | 
				
			|||||||
     * This method is called by SDL using JNI.
 | 
					     * This method is called by SDL using JNI.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static boolean isChromebook() {
 | 
					    public static boolean isChromebook() {
 | 
				
			||||||
        if (getContext() == null) {
 | 
					        // https://stackoverflow.com/questions/39784415/how-to-detect-programmatically-if-android-app-is-running-in-chrome-book-or-in
 | 
				
			||||||
            return false;
 | 
					        if (getContext() != null) {
 | 
				
			||||||
 | 
					            if (getContext().getPackageManager().hasSystemFeature("org.chromium.arc")
 | 
				
			||||||
 | 
					                || getContext().getPackageManager().hasSystemFeature("org.chromium.arc.device_management")) {
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        return getContext().getPackageManager().hasSystemFeature("org.chromium.arc.device_management");
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Running on AVD emulator
 | 
				
			||||||
 | 
					        boolean isChromebookEmulator = (Build.MODEL != null && Build.MODEL.startsWith("sdk_gpc_"));
 | 
				
			||||||
 | 
					        return isChromebookEmulator;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user